<?php
class MySQL{
	
	var $dbhost;
	var $dbuser;
	var $dbpass;
	var $dbname;
	
	function MySQL($dbhost,$dbuser,$dbpass,$dbname){
		$this->dbhost = $dbhost;
		$this->dbuser = $dbuser;
		$this->dbpass = $dbpass;
		$this->dbname = $dbname;		
		$this->connect();				
	}
	function connect(){
		@mysql_pconnect($this->dbhost,$this->dbuser,$this->dbpass) or die('<!-- Không Thể Kết Nối CSDL -->');
		@mysql_select_db($this->dbname) or die('<!-- Không Thể Kết Nối Với Tên '.$this->dbname."-->");
		return true;
	}
	function fetch_array($sql){
		$data = array();
		$rs = mysql_query($sql);
		while($rows = mysql_fetch_array($rs)){
				$data[] = $rows;
		}		
		return $data;
	}	
	function fetch_assoc($sql){
		$data = array();
		$rs = mysql_query($sql);
		while($rows = mysql_fetch_assoc($rs)){
				$data = $rows;
		}		
		return $data;
	}
	function num_rows($sql){		
		$rs = mysql_query($sql);			
		return mysql_num_rows($rs);;
	}	
}
?>